Reloading Changes

The CAS spring cloud configuration server is able to consume properties and settings via the profiles outlined here. The server is constantly monitoring changes to the underlying property sources automatically, but has no way to broadcast those changes to its own clients, such as the CAS server itself, which would act as a client of the configuration server expecting change notifications to quietly reload its configuration.

Therefore, in order to broadcast such change events CAS presents various endpoints that allow the adopter to refresh the configuration as needed. This means that an adopter would change a required CAS settings and then would submit a request to CAS to refresh its current state. All CAS internal components that are affected by the external change are quietly reloaded and the setting takes immediate effect, completely removing the need for container restarts or CAS re-deployments.

Do Not Discriminate!

Most if not all CAS settings are eligible candidates for reloads. CAS should be smart enough to reload the appropriate configuration, regardless of setting/module that ends up using that setting. All is fair game, as the entire CAS web application inclusive of all modules and all relevant settings may be completely and utterly reloadable. If you find an instance where this statement does not hold, please speak up.

To see the relevant list of CAS properties for this feature, please review this guide.

Reload Strategy

CAS uses Spring Cloud to manage the internal state of the configuration. The configuration server that is provided by Spring Cloud embedded in CAS is constantly monitoring sources that house CAS settings and upon changes will auto-refresh itself.

Application Context

The CAS application context and runtime environment that contains all Spring components and bean definitions can be reloaded using the following administrative endpoint:

Actuator Endpoints

The following endpoints are provided by Spring Cloud:

Provides information about Spring Cloud enabled/disabled features.

Features

FeaturesEndpoint.features()

org.springframework.cloud.client.actuator.FeaturesEndpoint

Refresh the application configuration via a `POST` to let components reload and recognize new values.

Collection

RefreshEndpoint.refresh()

org.springframework.cloud.endpoint.RefreshEndpoint

Updates each instances environment with the specified key/value pair across multiple instances.

EnvironmentBusEndpoint.busEnv(java.lang.String,java.lang.String)

org.springframework.cloud.bus.endpoint.EnvironmentBusEndpoint

Updates each instances environment with the specified key/value pair across multiple instances.

EnvironmentBusEndpoint.busEnvWithDestination(java.lang.String,java.lang.String,java.lang.String[])

org.springframework.cloud.bus.endpoint.EnvironmentBusEndpoint

Clears the RefreshScope cache and rebinds configuration properties.

RefreshBusEndpoint.busRefresh()

org.springframework.cloud.bus.endpoint.RefreshBusEndpoint

Clears the RefreshScope cache and rebinds configuration properties.

RefreshBusEndpoint.busRefreshWithDestination(java.lang.String[])

org.springframework.cloud.bus.endpoint.RefreshBusEndpoint

Control the status of the Spring Cloud Service Registry.

ResponseEntity

ServiceRegistryEndpoint.getStatus()

org.springframework.cloud.client.serviceregistry.endpoint.ServiceRegistryEndpoint

Control the status of the Spring Cloud Service Registry.

ResponseEntity

ServiceRegistryEndpoint.setStatus(java.lang.String)

org.springframework.cloud.client.serviceregistry.endpoint.ServiceRegistryEndpoint


Configuration

Changes in CAS configuration settings and properties can be reloaded using the strategies outlined below.

Standalone

In the event that the standalone configuration profile is used to control and direct settings and Spring Cloud configuration server is disabled, CAS will begin to automatically watch and monitor the configuration files indicated by the profile and will auto-reload the state of the runtime application context automatically. You may also attempt to refresh settings manually via the CAS admin endpoints.

Support is enabled by including the following dependency in the WAR overlay:

1
2
3
4
5
<dependency>
  <groupId>org.apereo.cas</groupId>
  <artifactId>cas-server-core-events-configuration</artifactId>
  <version>${cas.version}</version>
</dependency>
1
implementation "org.apereo.cas:cas-server-core-events-configuration:${project.'cas.version'}"
1
2
3
4
5
6
7
8
9
dependencyManagement {
  imports {
    mavenBom "org.apereo.cas:cas-server-support-bom:${project.'cas.version'}"
  }
}

dependencies {  
  implementation "org.apereo.cas:cas-server-core-events-configuration"
}

Spring Cloud

Clients of the configuration server (i.e. CAS server web application) do also expose a /refresh endpoint that allow one to refresh the configuration based on the current state of the configuration server and reconfigure the application runtime without the need to restart the JVM.

1
curl -X POST https://cas.server.url/cas/actuator/refresh

See this guide to learn more about various monitoring endpoints, etc.